/*
go可以在函数中返回多个值
https://www.bilibili.com/video/BV1gf4y1r79E/?p=7&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
*/
package main

import (
	"fmt"
)

func foo1(a string, b string) string {
	return a + " " + b
}

// 1. 返回多个返回值
func foo2(a string, b string) (int, int) {
	return 666, 777
}

// 2. 返回多个返回值（且有形参名称）
func foo3(a string, b string) (r1 int, r2 int) {
	fmt.Printf("in foo3 赋值之前： r1 = %d, r2 = %d\n", r1, r2)

	r1 = 1000
	r2 = 2000
	return
}

// 3. 类似2
func foo4(a string, b string) (r1, r2 int) {
	r1 = 1004
	r2 = 2004
	return
}

func main() {
	fmt.Println("hello, return val")
	fmt.Println(foo1("foo", "bar"))

	//fmt.Println(foo2("foo", "bar")) error
	ret1, ret2 := foo2("foo", "bar")
	fmt.Printf("%d, %d\n", ret1, ret2)

	ret1, ret2 = foo3("foo", "bar")
	fmt.Printf("%d, %d\n", ret1, ret2)

	ret1, ret2 = foo4("foo", "bar")
	fmt.Printf("%d, %d\n", ret1, ret2)

}
